Moving EXIF data retrieval to Image class
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Thu, 21 Apr 2005 11:28:56 +0000 (11:28 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Thu, 21 Apr 2005 11:28:56 +0000 (11:28 +0000)
includes/Image.php
includes/ImagePage.php

index 888c56c..0db9aea 100644 (file)
@@ -3,6 +3,10 @@
  * @package MediaWiki
  */
 
+if ( $wgShowEXIF ) {
+       require_once ( 'exifReader.inc' ) ;
+       }
+
 /**
  * Class to represent an image
  * 
@@ -1107,6 +1111,26 @@ class Image
                $db->freeResult( $res );
                return $retVal;
        }
+       
+       function retrieveExifData () {
+               global $wgShowEXIF ;
+               if ( ! $wgShowEXIF ) return array () ;
+
+               $file = $this->getImagePath () ;
+               $per = new phpExifReader ( $file ) ;
+               $per->processFile () ;
+               $a = $per->getImageInfo() ;
+               unset ( $a["FileName"] ) ;
+               unset ( $a["Thumbnail"] ) ;
+               return $a ;
+               }
+               
+       function getExifData () {
+               return $this->retrieveExifData () ;
+               }
+       
+       function storeExifData () {
+               }
 
 } //class
 
index eefb7d0..ab2ea39 100644 (file)
@@ -11,10 +11,6 @@ if( !defined( 'MEDIAWIKI' ) )
 
 require_once( 'Image.php' );
 
-if ( $wgShowEXIF ) {
-       require_once ( 'exifReader.inc' ) ;
-       }
-
 /**
  * Special handling for image description pages
  * @package MediaWiki
@@ -62,17 +58,15 @@ class ImagePage extends Article {
                {
                global $wgOut , $wgShowEXIF ;
                if ( ! $wgShowEXIF ) return ;
-               $file = $this->img->getImagePath () ;
-               $per = new phpExifReader ( $file ) ;
-               $per->processFile () ;
+
+               # Get the EXIF data
+               $exif = $this->img->getExifData () ;
+               if ( count ( $exif ) == 0 ) return ; # No EXIF data
                
+               # Create the table
                $r = "<table border='1' cellspacing='0' cellpadding='0' align='right'>" ;
                $r .= "<caption>EXIF data</caption>" ;
-               $a = $per->getImageInfo() ;
-               if ( count ( $a ) == 0 ) return ; # No EXIF data
-               unset ( $a["FileName"] ) ;
-               unset ( $a["Thumbnail"] ) ;
-               foreach ( $a AS $k => $v ) {
+               foreach ( $exif AS $k => $v ) {
                        $r .= "<tr>" ;
                        $v = str_replace ( "\0" , "" , $v ) ;
                        $r .= "<th><small>" . htmlspecialchars ( $k ) . "</small></th>" ;